package com.yonyou.cyxdms.sysAuth.service.service.log.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yonyou.cyxdms.framework.bean.dto.user_info.LoginInfoDto;
import com.yonyou.cyxdms.sysAuth.service.entity.OperateLogPO;
import com.yonyou.cyxdms.sysAuth.service.mapper.OperateLogMapper;
import com.yonyou.cyxdms.sysAuth.service.service.log.OperateLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;


/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author maxingjian
 * @since 2019-10-21
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLogPO> implements OperateLogService {
    //日志对象
    private static final Logger logger = LoggerFactory.getLogger(OperateLogServiceImpl.class);
    @Autowired
    OperateLogMapper operateLogMapper;


    @Override
    public void recordLog(LoginInfoDto loginInfoDto, String operateType, String operateContent, String remark) {
        //LoginInfoDto loginInfoDto = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        OperateLogPO operatelogpo = new OperateLogPO();
        operatelogpo.setAppId(loginInfoDto.getAppId());
        operatelogpo.setCompanyId(loginInfoDto.getCompanyId());
        operatelogpo.setOwnerCode(loginInfoDto.getOwnerCode());
        operatelogpo.setOperateContent(operateContent);
        operatelogpo.setRemark(remark);
        operatelogpo.setOperateType(Integer.parseInt(operateType));
        operatelogpo.setOperateDate(LocalDateTime.now());
        operatelogpo.setOperator(loginInfoDto.getUserId());
        operatelogpo.setUserOrgId(loginInfoDto.getUserOrgId());
        operateLogMapper.insert(operatelogpo);
    }
}
